import React, { useEffect, useState } from 'react';
import {
  List,
  WingBlank,
} from 'antd-mobile';

const { Item } = List;

function Location() {
  const l: BaseObject = {};
  const [location, setLocation] = useState(l);
  useEffect(() => {
    window.HWH5.getLocation({ type: 1 }).then((data) => {
      setLocation(data);
      console.log(data);
    }).catch((error) => {
      console.log('获取位置信息异常', error);
    });
  }, []);
  return (
    <WingBlank>
      <List renderHeader={() => '定位信息'}>
        {Object.keys(location).map((name: string) => (
          <Item extra={location[name]}>{name}</Item>
        ))}
      </List>
    </WingBlank>
  );
}

export default Location;
